package com.yunshipei.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.yunshipei.base.BaseActivity;
import com.yunshipei.base.BaseIntentBuilder;
import com.yunshipei.enterplorer.R;
import com.yunshipei.model.MainExtraBean;
import com.yunshipei.ui.fragment.ModifyPwdFragment;

public class ModifyPasswordActivity extends BaseActivity {

    private static final String EXTRA_MAIN_DATA = "extra.main.data";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_modify_password);
        MainExtraBean mainExtraBean = (MainExtraBean) getIntent().getSerializableExtra(EXTRA_MAIN_DATA);
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(ModifyPwdFragment.class.getName());
        if (fragment == null) {
            fragment = ModifyPwdFragment.newInstance(mainExtraBean);
            getSupportFragmentManager().beginTransaction().add(R.id.fl_modify_pwd, fragment, fragment.getClass().getName()).commit();
        }
    }

    public static class ModifyPwdActivityIntentBuilder extends BaseIntentBuilder {

        public ModifyPwdActivityIntentBuilder(Context context) {
            super(context);
        }

        public ModifyPwdActivityIntentBuilder setMainData(MainExtraBean mainData) {
            getIntent().putExtra(EXTRA_MAIN_DATA, mainData);
            return this;
        }

        @Override
        protected Class<?> getTargetClazz() {
            return ModifyPasswordActivity.class;
        }
    }
}
